/**
 * 比较版本号, 3段式版本号： X.X.X
 * @param {*} newVersion 
 * @param {*} oldVersion 
 * 
 * @return -1, 0, 1
 *    -1: newVersion < oldVersion
 *     0: newVersion == oldVersion
 *     1: newVersion > oldVersion
 */
 export function compareVersion (newVersion, oldVersion) {
  if (newVersion === oldVersion) return 0
  if (!newVersion) return 0
  if (!oldVersion) return 1
  let version1 = newVersion.split('.').map(item => isNaN(item) ? 0 : Number(item))
  let version2 = oldVersion.split('.').map(item => isNaN(item) ? 0 : Number(item))
  if (version1[0] > version2[0]) {
    return 1
  } else if (version1[0] < version2[0]) {
    return -1
  } else {
    if (version1[1] > version2[1]) {
      return 1
    } else if (version1[1] < version2[1]) {
      return -1
    } else {
      if (version1[2] > version2[2]) {
        return 1
      } else if (version1[2] < version2[2]) {
        return -1
      } else {
        return 0
      }
    }
  }
}